<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        const pi = 3.14;
        const sum = function (a, b) {
            return a + b;
        };
        let sum1 = (a, b) => {return a + b};
        window.onload = function () {
           let person = {
               name: "zhangsan",
               age: 18
           };
           document.getElementById("div").innerHTML =
           `<h1>${person.name}</h1>`;
        };
        //扩展运算符
        let arr = [1, 2];
        let arr2 = [...arr, 6, 7];
        console.log(sum(...arr));
        //收集元素
        let getSum = function (...args) {
            let sum = 0;
            for (let i = 0; i < args.length; i++) {
                sum += args[i];
            }
            return sum;
        };
        console.log(getSum(1, 2, 3, 4, 5));
        //解构
        let arr = [1, 2, 3];
        let [a, ar] = arr;
        console.log(a, ar);

    </script>
</head>
<body>
<div id="div">

</div>
<!--<input type="button" value="session"-->
<!--       onclick="sessionSave()">-->
<!--<input type="button" value="sessionGet"-->
<!--       onclick="sessionGet()">-->
<script>

<!--    function sessionSave() {-->
<!--        // sessionStorage.setItem("name", "zhangsan");-->
<!--        // setItem(key, value) 方法用于在 sessionStorage 中存储数据-->
<!--        // 参数 key: 要存储的数据的键名-->
<!--        // 参数 value: 要存储的数据的值（会自动转换为字符串）-->
<!--        // 此方法会将数据保存在当前会话中，关闭浏览器标签页或窗口后数据会被清除-->
<!--        sessionStorage.setItem("name", "zhangsan");-->
<!--alert("保存成功")-->
<!--    }-->
<!--    function sessionGet() {-->
<!--    let user = sessionStorage.getItem("name");-->
<!--    alert(user);-->
<!--    }-->
</script>
</body>
</html>